home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / os2 / rexxcolr.zip / COLOR.CMD
OS/2 REXX Batch file  |  1992-09-15  |  5KB  |  111 lines

  1. /*>>>>>>>>>>>>>>>>>>>>>>      REXX/2   COLOR.CMD     <<<<<<<<<<<<<<<<<<<<<<<<<*//*
  2.  
  3. After switching to OS/2, I found myself missing the convenience of ansi.sys
  4. and decided to replace some of my batch files with REXX files.  This is my
  5. first attempt.  Wish I had something more than just the online info. Oh well!
  6.  
  7. Minimal to non-existant error checking.  No provision for an Environment 
  8. variable to maintain color selection between "cmd" files.
  9.  
  10. You may enter only the FG color at any prompt, & it will give you that 
  11. foreground color with the default background - black.
  12.  
  13. Doubt this is necessary, but...  ANSI should be ON. 
  14.  
  15. There is probably a better & more REXX-like way to do this but.....   
  16.  
  17. I am not responsible for damage that might result from improper use or misuse
  18. of this file.
  19.                                                               Paul Smith
  20.                                                            Catfish Bend BBS
  21.                                                              319-752-0953     */
  22. /*------------------------[ Code Starts Next Line ]---------------------------*/
  23. '@echo off'
  24.  
  25. CALL RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  26. CALL SysLoadFuncs
  27.  
  28. ARG fg bg                                     
  29.  
  30. IF  fg <> "" THEN                             /* see if 2 commandline args */
  31.   DO                                          /* no check for improper args */
  32.     IF bg ='' then bg=0                       /* Lazy people get black background */
  33.     IF fg > 15 | bg > 7 then SIGNAL Menu      /* Serious help needed here */
  34.     IF fg > 7  THEN                           /* High intensity required */
  35.            SAY ""fg-8+30";"bg+40"m"
  36.     ELSE                                      /* Normal intensity indicated */
  37.            SAY""fg+30";"bg+40"m"
  38.    
  39.     CALL SYSDROPFUNCS
  40.     CLS; EXIT                                 /* Colors set so exit */
  41.   END                                         /* Last chance to get it right */
  42.  
  43. MENU:
  44.  
  45. CALL SysCurState OFF
  46.  
  47. SAY""; CLS; fg=29; hfg=29; Row=12; col=4; bg=40 /* Default color & set variables */
  48. SAY">        ╥─╖ ╓── ╖ ╓ ╖ ╓     ╓─╖ ╓── ╓─╥─╖     ╓─╖ ╓─╖ ╥   ╓─╖ ╥─╖ ╓─╖       <"                   
  49. SAY">        ║ ║ ║   ║ ║ ║ ║     ║   ║     ║       ║   ║ ║ ║   ║ ║ ║ ║ ║         <"                   
  50. SAY">        ╟─╜ ╟─  ╙─╖ ╙─╖     ╙─╖ ╟─    ║  ───  ║   ║ ║ ║   ║ ║ ╟─╜ ╙─╖       <"                   
  51. SAY">        ║ ║ ║   ║ ║ ║ ║       ║ ║     ║       ║   ║ ║ ║   ║ ║ ║ ║   ║       <"                   
  52. SAY">        ╨ ╙ ╙── ╜ ╙ ╜ ╙     ╙─╜ ╙──   ╨       ╙─╜ ╙─╜ ╙── ╙─╜ ╨ ╙ ╙─╜       <"                   
  53. SAY
  54. SAY
  55. SAY"                        F  O  R  E  G  R  O  U  N  D"
  56. SAY
  57. SAY"        0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15"
  58. SAY"  B"
  59. SAY"  A 0  "      
  60. SAY"  C 1  "       
  61. SAY"  K 2  "       
  62. SAY"  G 3  "       
  63. SAY"  R 4  "       
  64. SAY"  O 5  "       
  65. SAY"  U 6  "       
  66. SAY"  N 7  "       
  67. SAY"  D    "
  68.  
  69. DO 8                                                   /* Paint low intensity  colors */
  70.    DO 8
  71.      fg=fg+1; col=col+4; SAY""row";"col"H"fg";"bg"mIBM "
  72.    END
  73.  
  74.    DO 8                                                /* Paint high intensity colors */
  75.      hfg=hfg+1; col=col+4; SAY""row";"col"H"hfg";"bg"mIBM "
  76.    END
  77.  
  78.    bg =bg+1; row=row+1; col=4; fg=29; hfg=29           /* reset variables */
  79. END
  80.  
  81. SAY"H Enter color selection as in [FG BG] Where FG is the foreground color   "
  82. SAY"      and BG is the background color.  There must be a space between FG BG.  H"
  83. SAY""
  84.  
  85. CALL SysCurState ON                                    /* Turn cursor back on */
  86.  
  87. PULL FG BG                                             /* Get user choices */
  88.  
  89. IF fg='' & bg='' THEN                                  /* No Choices entered so */
  90.   DO
  91.     SIGNAL Menu                                        /* Menu needed here */
  92.   END
  93.  
  94. IF fg > 15 | bg > 7  THEN                              /* Clown Check & Exit */
  95.   DO
  96.      SIGNAL Menu
  97.   END                                                 
  98.  
  99. IF BG='' THEN BG=0                                     /* Lazy man's black Backgroung */
  100.  
  101. IF fg > 7 THEN 
  102.   DO
  103.     SAY ""fg-8+30";"bg+40"m"                       /* Choices entered so act */
  104.   END
  105.  
  106. ELSE 
  107.     SAY""FG+30";"BG+40"m"
  108.  
  109. CLS                                                    /* Colorize screen & clear */
  110. CALL SYSDROPFUNCS
  111.